import React, { Component } from 'react'
// 7.导入store
import store from './store/index'

export default class App extends Component {
  render() {
    console.log(store.getState().count);
    return (
      <div>
        App
        {/* 8.在组件中通过store.getState() 来获取全局状态 */}
        {store.getState().count}

        <button onClick={() => {
          store.dispatch({ type: 'add' })
        }}>加1</button>

        <button onClick={() => {
          store.dispatch({ type: 'reduce' })
        }}>减1</button>

        <button onClick={() => {
          store.dispatch({ type: 'addNum', payload: 10 })
        }}>加10</button>

        <button onClick={() => {
          store.dispatch({ type: 'reduceNum', payload: 10 })
        }}>减10</button>

      </div>
    )
  }
}
